package com.upb.webserver.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@Getter
@ToString
@AllArgsConstructor
@Slf4j
public enum MessageTypeEnum {
    WARN(0, "warn"),
    INFO(1, "inform");

    private byte id;
    private String description;

    MessageTypeEnum(int id, String description) {
        this.id = (byte) id;
        this.description = description;
    }


    /**
     * @param id
     * @return
     */
    public static MessageTypeEnum getById(byte id) {
        for (MessageTypeEnum value : MessageTypeEnum.values()) {
            if (value.id == id) {
                return value;
            }
        }
        return null;
    }

    public byte getId() {
        return this.id;
    }
}
